var express = require('express');
var router = express.Router();

const sqlconfig = require('../mysql/sqlconfig')
const JWT = require('../utils/jwt')

router.get('/searchCssList', function async (req, res, next) {
  if (JWT.verifyToken(req.headers.token)) {
    const selectSql = "select * from cssquestion";
    sqlconfig.query(selectSql, (err, results) => {
      // 查询数据失败
      if (err) {
        console.log(err.message)
        return
      }
      res.status(200).send({
        code: 200,
        message: '查询成功！',
        data: results
      })
      // 查询数据成功
      // 注意：如果执行的是 select 查询语句，则执行的结果是数组
      console.log(results)
    })
  } else {
    res.status(200).send({
      code: -1,
      message: '请检查登录状态！',
    })
  }


})
module.exports = router;
